Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERNAL: add PipeOperationImpl to reduce duplicate code #872

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

oliviarla
Copy link
Collaborator

@oliviarla oliviarla commented Jan 22, 2025

๐Ÿ”— Related Issue

  • ์•ž์œผ๋กœ pipe operation implementation ๋ณ€๊ฒฝ ์ง€์ ์ด ๋งŽ์•„์งˆ ๊ฒƒ์„ ๊ณ ๋ คํ•˜์—ฌ PipeOperationImpl ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด๋ฅผ ๊ฐ๊ฐ์˜ ํด๋ž˜์Šค๊ฐ€ ์ƒ์†๋ฐ›๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • ๋˜ํ•œ, ์ด์ „์— pipe_error๊นŒ์ง€ ์ฝ๋Š” ๋กœ์ง์„ CollectionPipedInsertOperationImpl์—๋งŒ ์ ์šฉํ–ˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์—, ํ•˜๋‚˜์˜ ์ถ”์ƒ ํด๋ž˜์Šค๋ฅผ ์ƒ์†๋ฐ›๋„๋ก ํ•˜์—ฌ CollectionPipedUpdateOperationImpl, CollectionPipedExistOperationImpl, CollectionBulkInsertOperationImpl์—๋„ ์ ์šฉํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.

โŒจ๏ธ What I did

  • handleLine, initialize ๋“ฑ์˜ ๋ฉ”์„œ๋“œ ์ค‘๋ณต๊ณผ static ํ•„๋“œ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • handleLine์—์„œ ๊ฐ ์—ฐ์‚ฐ(insert/exist/update/bulk insert)๋งˆ๋‹ค ๋‹ค๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•˜๋Š” ๋ถ€๋ถ„์€ ์ถ”์ƒ ๋ฉ”์„œ๋“œ๋กœ ๋นผ ๊ฐ ํด๋ž˜์Šค์—์„œ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • wasCancelled ๋ฉ”์„œ๋“œ๋Š” ์—ฐ์‚ฐ๋งˆ๋‹ค ๋‹ค๋ฃฐ CANCELLED ์ƒํƒœ๊ฐ€ ๋‹ฌ๋ผ ๊ฐ ํด๋ž˜์Šค์—์„œ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • getInsert/ getExist / getUpdate ๋ฉ”์„œ๋“œ๋Š” ํ˜•๋ณ€ํ™˜์ด ํ•„์š”ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ ํด๋ž˜์Šค์—์„œ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

@oliviarla
Copy link
Collaborator Author

@uhm0311 @jhpark816 ๋‹ค์‹œ ๋ฆฌ๋ทฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐ

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ถ”๊ฐ€ ๋ฆฌ๋ทฐ

} else {
index++;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค.
isNotPiped() ๊ฒฝ์šฐ์—์„œ NOT_MY_KEY ์‘๋‹ต์„ ๋ฐ›์œผ๋ฉด,
single key pipe์ด๋“  multi key pipe์ด๋“  ๊ด€๊ณ„์—†์ด ์•„๋ž˜ ๋กœ์ง์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

       addRedirectSingleKeyOperation(line, keys.get(index));
       transitionState(OperationState.REDIRECT);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ œ์‹œํ•˜์‹  ๋กœ์ง์„ ์‚ฌ์šฉํ•ด๋„ ์ •์ƒ ๋™์ž‘ํ•  ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

isNotPiped์ธ ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•˜๋ ค๋ฉด 1. ์ฒ˜์Œ๋ถ€ํ„ฐ ๋…ธ๋“œ์— ๋ณด๋‚ผ ์—ฐ์‚ฐ์˜ ํ‚ค๊ฐ€ 1๊ฐœ๋ฟ์ด๊ฑฐ๋‚˜, 2. ๋งจ ๋งˆ์ง€๋ง‰ ์—ฐ์‚ฐ๋งŒ ๋นผ๊ณ  ์ด๋ฏธ ์ˆ˜ํ–‰๋œ ์ƒํƒœ์—์„œ switchover/redirect๋กœ ์ธํ•ด ๋‹ค์‹œ ์š”์ฒญ์„ ๋ณด๋ƒˆ์„ ๋•Œ ๋ฟ์ž…๋‹ˆ๋‹ค.

  • 1๋ฒˆ ์ผ€์ด์Šค
    • ๋‚ด๋ถ€์— ํ‚ค๊ฐ€ ํ•˜๋‚˜๋ฟ์ธ single key redirect handler๋ฅผ ์ƒ์„ฑํ•˜์—ฌ, ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•  ์บ์‹œ ๋…ธ๋“œ๋ฅผ ์ฐพ๊ณ  ํ•ด๋‹น ํ‚ค์— ๋Œ€ํ•ด์„œ๋งŒ ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.
  • 2๋ฒˆ ์ผ€์ด์Šค
    • ๊ธฐ์กด์— NOT_MY_KEY ์‘๋‹ต์„ ๋ฐ›์•˜๋‹ค๋ฉด ์ด๋ฏธ ๋‚ด๋ถ€์— ํ‚ค๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ ์กด์žฌํ•˜๋Š” multi key redirect handler๊ฐ€ ์ƒ์„ฑ๋œ ์ƒํƒœ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด ํ•ธ๋“ค๋Ÿฌ์— ๋‹จ์ˆœํžˆ ํ‚ค๋งŒ ์ถ”๊ฐ€ํ•˜๊ฒŒ ๋˜์–ด ์ดํ›„ ๋™์ž‘์— ๋ฌธ์ œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
    • redirect handler๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ๋‚ด๋ถ€์— ํ‚ค๊ฐ€ ํ•˜๋‚˜๋ฟ์ธ single key redirect handler๋ฅผ ์ƒ์„ฑํ•˜์—ฌ, ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•  ์บ์‹œ ๋…ธ๋“œ๋ฅผ ์ฐพ๊ณ  ํ•ด๋‹น ํ‚ค์— ๋Œ€ํ•ด์„œ๋งŒ ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

@jhpark816 jhpark816 requested a review from brido4125 January 31, 2025 03:10
@jhpark816 jhpark816 merged commit 451644c into naver:develop Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants